<template>
    <div>
        <!-- 层级选择 -->
        <a-select v-bind="$attrs" v-on="$listeners" :placeholder="placeholder" v-model="currentValue" allowClear>
            <a-icon v-if="fetching" style="color: #096dd9" slot="suffixIcon" type="loading" />
            <a-spin v-if="fetching" slot="notFoundContent" size="small" />
            <a-select-option v-for="i in list" :key="i.value" :value="i.value">{{
               i.label
            }}</a-select-option>
        </a-select>
    </div>
</template>
<script>

export default {
    inheritAttrs: false,
    name: 'SelectHierarchy',
    props: {
        // v-model绑定的数据
        value: {
            type: [Array, String, Object],
        },
        // placeholder
        placeholder: {
            type: String,
            default: () => '请选择',
        },
    },
    data() {
        return {
            fetching: false,
            list: [
                {
                    label: '公司',
                    value: 'CO',
                },
                {
                    label: '分公司',
                    value: 'BC',
                },
                {
                    label: '项目/机关',
                    value: 'PD',
                },
            ],
        }
    },

    mounted() {},
    methods: {},
    computed: {
        // 转换绑定的选中数据，与v-model同步
        currentValue: {
            get: function () {
                return this.value || void 0
            },
            set: function (value) {
                this.$emit('input', value)
            },
        },
    },
}
</script>
